<%-- 
    Document   : db1
    Created on : 2014/8/19, 下午 01:26:13
    Author     : gjun
--%>

<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
    String username=request.getParameter("username");
    String tel=request.getParameter("tel");
    String birthday=request.getParameter("birthday");
    Class.forName("com.mysql.jdbc.Driver");//貼上資料庫路徑Driver/jdbc:mysq1.......
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/javadb", "root", "root");
    Statement st=con.createStatement();
    String sql="insert into person(username,tel,birthday)value('"+username+"','"+tel+"','"+birthday+"')";
    //抓值 sql 
    System.out.println(sql);//印出結果
    int x= st.executeUpdate(sql);//抓次數
    st.close();
    con.close();

%>  
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>insert2</title>
    </head>
    <body>
        <h1>insert2</h1>
        新增了 <%= x %> 筆資料
        <%= sql %>
        <a href="insert1.jsp">繼續新增</a>
        <a href="list.jsp">清單</a>
    </body>
</html>
